package com.edu.exam.entity.curriculum.questionbank;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.DecimalMax;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 论述题质量评估实体类
 * 所属模块：B-02 题库管理模块
 * 对应数据库表：essay_quality_assessment
 *
 * 管理论述题的质量评估信息，包括内容质量、可读性、难度适配性等指标。
 * 支持质量评估的创建、查询、历史记录管理。
 * 关联论述题实体、评估人等信息。
 *
 * @author System
 * @version 1.0.0
 */
@Entity
@Comment("论述题质量评估表")
@SQLDelete(sql = "UPDATE essay_quality_assessment SET is_deleted = true, delete_time = CURRENT_TIMESTAMP WHERE id = ?")
@Where(clause = "is_deleted = false")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class EssayQualityAssessment {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @NotNull(message = "题目ID不能为空")
    @Column(name = "question_id", nullable = false)
    @Comment("关联题目ID")
    private Long questionId;

    @NotNull(message = "评估人ID不能为空")
    @Column(name = "assessor_id", nullable = false)
    @Comment("评估人ID")
    private Long assessorId;

    @Column(name = "assessor_name", length = 100)
    @Comment("评估人姓名")
    private String assessorName;

    @DecimalMin(value = "0.0", message = "内容质量分数不能为负数")
    @DecimalMax(value = "5.0", message = "内容质量分数不能超过5分")
    @Column(name = "content_quality_score", precision = 3, scale = 2)
    @Comment("内容质量分数")
    private BigDecimal contentQualityScore;

    @DecimalMin(value = "0.0", message = "可读性分数不能为负数")
    @DecimalMax(value = "5.0", message = "可读性分数不能超过5分")
    @Column(name = "readability_score", precision = 3, scale = 2)
    @Comment("可读性分数")
    private BigDecimal readabilityScore;

    @DecimalMin(value = "0.0", message = "难度适配性分数不能为负数")
    @DecimalMax(value = "5.0", message = "难度适配性分数不能超过5分")
    @Column(name = "difficulty_appropriateness_score", precision = 3, scale = 2)
    @Comment("难度适配性分数")
    private BigDecimal difficultyAppropriatenessScore;

    @DecimalMin(value = "0.0", message = "清晰度分数不能为负数")
    @DecimalMax(value = "5.0", message = "清晰度分数不能超过5分")
    @Column(name = "clarity_score", precision = 3, scale = 2)
    @Comment("清晰度分数")
    private BigDecimal clarityScore;

    @DecimalMin(value = "0.0", message = "相关性分数不能为负数")
    @DecimalMax(value = "5.0", message = "相关性分数不能超过5分")
    @Column(name = "relevance_score", precision = 3, scale = 2)
    @Comment("相关性分数")
    private BigDecimal relevanceScore;

    @DecimalMin(value = "0.0", message = "新颖性分数不能为负数")
    @DecimalMax(value = "5.0", message = "新颖性分数不能超过5分")
    @Column(name = "originality_score", precision = 3, scale = 2)
    @Comment("新颖性分数")
    private BigDecimal originalityScore;

    @DecimalMin(value = "0.0", message = "综合分数不能为负数")
    @DecimalMax(value = "5.0", message = "综合分数不能超过5分")
    @Column(name = "overall_score", precision = 3, scale = 2)
    @Comment("综合分数")
    private BigDecimal overallScore;

    @Column(name = "assessment_status", length = 20)
    @Comment("评估状态")
    private String assessmentStatus;

    @Column(name = "detailed_feedback", columnDefinition = "TEXT")
    @Comment("详细反馈")
    private String detailedFeedback;

    @Column(name = "improvement_suggestions", columnDefinition = "TEXT")
    @Comment("改进建议")
    private String improvementSuggestions;

    @Column(name = "strength_points", columnDefinition = "TEXT")
    @Comment("优点")
    private String strengthPoints;

    @Column(name = "weakness_points", columnDefinition = "TEXT")
    @Comment("缺点")
    private String weaknessPoints;

    @Column(name = "assessment_tags", columnDefinition = "TEXT")
    @Comment("评估标签(JSON格式)")
    private String assessmentTags;

    @NotNull(message = "创建时间不能为空")
    @Column(name = "created_time", nullable = false)
    @Comment("创建时间")
    private LocalDateTime createdTime;

    @NotNull(message = "更新时间不能为空")
    @Column(name = "updated_time", nullable = false)
    @Comment("更新时间")
    private LocalDateTime updatedTime;

    @Column(name = "is_deleted", nullable = false)
    @Comment("是否删除")
    @Builder.Default
    private Boolean isDeleted = false;

    @Column(name = "delete_time")
    @Comment("删除时间")
    private LocalDateTime deleteTime;

    @Column(name = "meta_data", columnDefinition = "TEXT")
    @Comment("扩展元数据(JSON格式)")
    private String metaData;

}
